package com.activity.exg4pcd;
import com.ui.exg4pcd.R;

import domain.businessEntity.cardinfo.CardInfo;
import domain.businessService.cardinfo.*;
import foundation.data.DataHelper;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
	public CardService service;
	public static DataHelper DATAHELPER;
	public String DATAFILENAME="myApp.db";
	public CardInfo card;
	Button btn_exchange;
	Button btn_edit;
	TextView textName;
	TextView textPhone;
	TextView textEmail;
	TextView textQQ;
	TextView textWeibo;
	TextView textSex;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		DATAHELPER=new DataHelper(getApplicationContext(), DATAFILENAME);
		card=new CardInfo();
//		card.setCardID(0);
//		card.setName("陈子为");
//		card.setPhone("123456789");
//		card.setEmail("329827904@qq.com");
//		card.setSex("男");
//		card.setQQ("329827904");
//		card.setWeibo("陳子為");
		setContentView(R.layout.activity_main);
		service=new CardService();	
//		service.saveMyCardInfo(card);
		card= service.getCardInfo(0);
		textName=(TextView) findViewById(R.id.ShowName);
		textPhone=(TextView) findViewById(R.id.ShowPhone);
		textEmail=(TextView) findViewById(R.id.ShowEmail);
		textQQ=(TextView) findViewById(R.id.ShowQQ);
		textWeibo=(TextView) findViewById(R.id.ShowWeibo);
		textSex=(TextView) findViewById(R.id.ShowSex);
		textName.setText(card.getName());
		textPhone.setText(card.getPhone());
		textEmail.setText(card.getEmail());
		textQQ.setText(card.getQQ());
		textWeibo.setText(card.getWeibo());
		textSex.setText(card.getSex());
		btn_exchange=(Button) findViewById(R.id.btnExchange);
		btn_edit=(Button) findViewById(R.id.btn_Edit);
		btn_exchange.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent =new Intent(MainActivity.this,ExchangeActivity.class);
				startActivity(intent);
			}
		});
		
		btn_edit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			Intent intent=new Intent(MainActivity.this,EditActivity.class)	;
			startActivity(intent);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
